﻿using Microsoft.EntityFrameworkCore;
using my_webapi_demo.Common;
using my_webapi_demo.Db.Entity;

namespace my_webapi_demo.Db;

public class HuaskyDbContext: DbContext
{
    public DbSet<ReportEntity> Report { get; set; }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        if (AppConfig.Settings.DbType == "SqlServer")
        {
            optionsBuilder.UseSqlServer(AppConfig.Settings.SqlserverConnection);
        }
        else if (AppConfig.Settings.DbType == "MySql")
        {
            optionsBuilder.UseMySql(AppConfig.Settings.MySqlConntextion, ServerVersion.AutoDetect(AppConfig.Settings.MySqlConntextion));
        }
    }
}
